﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SC.GirdManage.Common;
using SC.GridManage.API.Write.Application.Command.PhysicalGrid;

namespace SC.GridManage.API.Write.Controllers
{
    /// <summary>
    /// 物理网格控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PhysicalGridController : ControllerBase
    {
        private readonly IMediator mediator;

        public PhysicalGridController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加物理网格的接口
        /// </summary>
        /// <param name="comand"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreatePhysicalGrid(CreatePhysicalGridCommand comand) { 
            return await mediator.Send(comand);
        }

        /// <summary>
        /// 删除物理网格的接口
        /// </summary>
        /// <param name="comand"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelPhysicalGrid(DelPhysicalCommand comand)
        {
            return await mediator.Send(comand);
        }
        /// <summary>
        /// 修改更新物理网格的接口
        /// </summary>
        /// <param name="comand"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdatePhysicalGrid(UpdatePhysicalGridCommand comand)
        {
            return await mediator.Send(comand);
        }
    }
}
